package google.sites.model;

import com.google.gdata.data.sites.*;

import java.text.MessageFormat;

/**
 * Created with IntelliJ IDEA.
 * User: Nuno
 * Date: 02-10-2013
 * Time: 16:51
 */
public class ContentEntryFactory {
    public static BaseContentEntry<?> create(Kind kind) throws Model.Exception {
        switch (kind) {
            case announcement:
                return new AnnouncementEntry();
            case announcementspage:
                return new AnnouncementsPageEntry();
            case comment:
                return new CommentEntry();
            case filecabinet:
                return new FileCabinetPageEntry();
            case listitem:
                return new ListItemEntry();
            case listpage:
                return new ListPageEntry();
            case webpage:
                return new WebPageEntry();
            case attachment:
            case webattachment:
                throw new Model.Exception(MessageFormat.format("Trying to create {0}. Please use upload command instead.", kind));
            default:
                throw new Model.Exception(MessageFormat.format("Unknown kind ''{0}''", kind));
        }
    }
}
